Repository navigation
Allow User.hashPassword/validatePassword to be overridden - #941
Conversation
|
What is the scenario where users should override |
There was a problem hiding this comment.
How throw new Error going to integrate with the existing validations? The request setting invalid password should return HTTP status 422 and a description of the validation error in the usual format. This code will IMO return 500 without enough details.
|
The idea is allow functions to be customized for built-in models as app developers often have specific logic for the user model. Whoever decides to override the default behavior should already know what they are doing. |
|
LGTM. |
|
please check why the CI builds are failing before you land this patch. |
e78ce81 to
4a9c5b6
Compare
Allow User.hashPassword/validatePassword to be overridden
|
User.create({...}, function (err,user){...} ) will cause an uncaught exception as |
|
Using the setter to hash passwords is pretty evil. We should find a better solution. Maybe the validatePassword should be set up as a validator on the User model. |
|
Once we have "persist" hook in place (loopbackio/loopback-datasource-juggler#559), it should be very easy to rework the User model to hash the password in this hook. Let's keep the scope of this discussion around the change in behaviour introduced by this pull request. @cleas can you post an example that works in |
|
@cleas can you please open a new github issue to track this problem? I'll post some ideas how to fix it there. |
/to @ritch @bajtos
The PR allows User.hashPassword and validatePassword methods to be overridden. It can be used as a workaround to #251.